layout.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { ConfigType } from "@/api/config";
  2. import { routing } from "@/i18n/routing";
  3. import { server } from "@/utils/server";
  4. import clsx from "clsx";
  5. import { Metadata, Viewport } from "next";
  6. import { NextIntlClientProvider } from "next-intl";
  7. import { getMessages } from "next-intl/server";
  8. import { Inter as FontSans } from "next/font/google";
  9. import { notFound } from "next/navigation";
  10. import { ReactNode } from "react";
  11. import "../editor.scss";
  12. import "../globals.scss";
  13. import { Providers } from "./providers";
  14. // 加载字体
  15. const fontSans = FontSans({
  16. subsets: ["latin"],
  17. variable: "--font-sans",
  18. });
  19. export const viewport: Viewport = {};
  20. export const metadata: Metadata = {
  21. title: {
  22. template: "%s | BCWin777",
  23. default: "BCWin777",
  24. },
  25. keywords: ["BCWin777"],
  26. description: "The home of over 30 million players",
  27. appleWebApp: {
  28. statusBarStyle: "black",
  29. },
  30. formatDetection: {
  31. email: false,
  32. address: false,
  33. telephone: false,
  34. },
  35. referrer: "no-referrer",
  36. other: {
  37. viewport: [
  38. "width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0," +
  39. " viewport-fit=cover ",
  40. ],
  41. },
  42. };
  43. interface Og {
  44. description: string;
  45. keywords: string;
  46. title: string;
  47. url: string;
  48. address: string;
  49. }
  50. interface System extends ConfigType {
  51. og: Og;
  52. }
  53. const getSystemReq = () => {
  54. return server.request<System>({
  55. url: "/v1/api/front/system/configs",
  56. method: "POST",
  57. });
  58. };
  59. export default async function LocaleLayout({
  60. children,
  61. params: { locale },
  62. }: {
  63. children: ReactNode;
  64. params: { locale: string };
  65. }) {
  66. if (!routing.locales.includes(locale as any)) {
  67. notFound();
  68. }
  69. const messages = await getMessages();
  70. const { data } = await getSystemReq();
  71. // console.log(data)
  72. return (
  73. <html lang={locale} suppressHydrationWarning>
  74. <head>
  75. {/* <!-- SEO Metadata --> */}
  76. {/* <meta name="description" content="{{ .Description }}" />
  77. <meta name="keywords" content="{{ .Keywords }}" />
  78. <meta name="author" content="Besoft" />
  79. <meta name="viewport" content="width=device-width, initial-scale=1.0" /> */}
  80. {/* <!-- Open Graph Metadata --> */}
  81. <meta property="og:title" content={data?.og?.title || ""} />
  82. <meta property="og:description" content={data?.og?.description || ""} />
  83. <meta property="og:image" content={data?.og?.url || ""} />
  84. <meta property="og:url" content={data?.og?.address || ""} />
  85. <meta property="og:type" content="website" />
  86. {/* <!-- Twitter Card Metadata --> */}
  87. <meta name="twitter:card" content={data?.og?.address || ""} />
  88. <meta name="twitter:title" content={data?.og?.title || ""} />
  89. <meta name="twitter:description" content={data?.og?.description || ""} />
  90. <meta name="twitter:image" content={data?.og?.url || ""} />
  91. </head>
  92. <body className={clsx("font-sans", fontSans.variable)}>
  93. <NextIntlClientProvider messages={messages}>
  94. <Providers themeProps={{ attribute: "class" }}>{children}</Providers>
  95. </NextIntlClientProvider>
  96. </body>
  97. </html>
  98. );
  99. }